﻿import { setupMessageTest, teardownMessageTest, MessageTestContext } from '../setup';
import { Assertions } from '@/utils/Assertions';
import { ActionName } from '@llonebot/onebot11/action/types';

describe('set_group_portrait', () => {
    let context: MessageTestContext;

    beforeAll(async () => {
        context = await setupMessageTest();
    });

    afterAll(() => {
        teardownMessageTest(context);
    });

    it('should set group portrait', async () => {
        const primaryClient = context.twoAccountTest.getClient('primary');

        // Use a dummy image URL or a local file if available. 
        // For this test, we'll assume a public image URL is available or skip if not.
        const imageUrl = 'https://avatars.githubusercontent.com/u/1010101?v=4'; // Example URL

        try {
            const response = await primaryClient.call(ActionName.GoCQHTTP_SetGroupPortrait, {
                group_id: context.testGroupId,
                file: imageUrl,
            });
            Assertions.assertSuccess(response, 'set_group_portrait');
        } catch (e) {
            console.warn('Skipping set_group_portrait test due to potential permission issues or network:', e);
        }
    });
});
